In this advance series of CSS tutorials, we will be learning how to create shadow effects on element content and box.
CSS Shadow Effect
In CSS we have two different properties to add shadow to text content or the element box.
-
text-shadow
-
box-shadow
CSS Text Shadow
With the help of
text-shadow
property, we can generate a shadow effect on the text content.
Syntax
Example
Add Color to shadow
We can also specify the color of the text's shadow, by putting a color value after horizontal and vertical length.
Syntax
Example
Shadow Blur Effect
Instead of showing the clear shadow, we can provide a blur effect on the shadow by specifying the blur value between color and horizontal parameters.
Syntax
Example
Multiple Shadows
We can also specify multiple shadows to single text content. To do so we use the comma to separate two different
text-shadow
values. By providing multiple shadows we get a smoot beautiful glow shadow.
Syntax
Example
Border Around the text
Using the text-shadow property we can create an effect on which a plain border covers the text content.
Example
Box Shadow
The
box-shadow
property applies the shadow effect on the element box. By using the box-shadow property we can create a 2-d effect on the element. And it accepts the same set of values like
text-shadow
property.
Syntax
Example
Create a Card using box-shadow Property
box-shadow
property is commonly used to create 2-D cards for the web pages.
Example
Summary
-
There are two properties that can create shadow effects
box-shadow
,text-shadow
. -
The
text-shadow
property creates a shadow effect only on the text content of the element. -
The
box-shadow
property creates a shadow effect on the complete element box. - Both properties accept the same value and parameters.
-
box-shadow
property is commonly used for creating cards.